<template>
	<div class="page-story-add">
		<el-input
			class="vertical-item"
			size="small"
			placeholder="请输入小说名"
			v-model="story.title"
			clearable>
		</el-input>
		<el-input
			class="vertical-item"
			type="textarea"
			placeholder="请输入正文"
			v-model="story.brief"
			clearable>
		</el-input>
		<el-button type="primary" @click="submit">提交</el-button>
	</div>
</template>

<script>
import * as web3CTR from '@/utils/web3-ctr'

export default {
	name: 'story-list',
	data(){
		return{
			story:{
				title:'',
				brief:''
			}
		}
	},
	created(){
	},
	methods:{
		submit(){
			web3CTR.deployStoryHead(this.story).then(async (headAddress)=>{
				if(headAddress){
					await web3CTR.addStoryToIndex({
						title: this.story.title,
						address: headAddress
					})
					this.$router.back()
				}
			})
		}
	}
}
</script>
